<template>
  <view class="content">
    <image class="logo" src="/static/logo.png"></image>
    <view>
      <text class="title">{{ pageIndex == 1 ? 'C端' : 'B端' }}</text>
    </view>

    <!-- 事例 -->
    <!-- NumberBox 步进器 -->
    <!-- <u-number-box v-model="value" @change="valChange"></u-number-box> -->

    <!-- 倒计时 毫秒级渲染 -->
    <!-- <u-count-down :time="30 * 60 * 60 * 1000" format="HH:mm:ss:SSS" autoStart millisecond></u-count-down> -->

    <button type="default" @click="clickChange">切换</button>
    <my-bar :selected="0"></my-bar>
  </view>
</template>

<script>
export default {
  data() {
    return {
      title: 'Hello',
      value: 0,
      pageIndex: 1,
    }
  },
  onLoad() {
    if (uni.getStorageSync('pageIndex')) {
      this.pageIndex = uni.getStorageSync('pageIndex')
      if (this.pageIndex === 2) {
        // this.list = this.$tarBarList.B
        uni.setStorageSync('pageIndex', 2)
      } else {
        // C端
        this.pageIndex = 1
        uni.setStorageSync('pageIndex', 1)
        // 获取热推商品数组
      }
    } else {
      // C端
      this.pageIndex = 1
      uni.setStorageSync('pageIndex', 1)
      // 获取热推商品数组
    }
  },

  methods: {
    valChange(e) {
      console.log('当前值为: ' + e.value)
    },

    clickChange() {
      if (this.pageIndex === 1) {
        uni.setStorageSync('pageIndex', 2)
      } else {
        uni.setStorageSync('pageIndex', 1)
      }
      //中转切换页
      uni.navigateTo({
        url: '/pages/index/changePage',
      })
    },
  },
}
</script>

<style>
.content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.logo {
  height: 200rpx;
  width: 200rpx;
  margin: 200rpx auto 50rpx auto;
}

.text-area {
  display: flex;
  justify-content: center;
}

.title {
  font-size: 36rpx;
  color: red;
}
</style>
